#include <bits/stdc++.h>
using namespace std;
const int maxn = 16+2;
bool isPrime[50], use[maxn];
int N, ans[maxn];

void solve(int cur){
    if(cur == N+1){
        if(isPrime[ans[N]+1]){
            cout << 1;
            for(int i=2; i<=N; ++i){
                cout << " " << ans[i];
            }
            cout << "\n";
        }
    }else{
        for (int i = 2; i <= N; ++i)
            if(!use[i] && isPrime[i+ans[cur-1]]){
            use[i] = true;
            ans[cur] = i;
            solve(cur + 1);
            use[i] = false;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    memset(isPrime, true, sizeof(isPrime));
    memset(use, false, sizeof(use));
    for (int i = 2; i <= 20; ++i) if(isPrime[i]){
        int t = 2;
        while(i*t<=40) {isPrime[i*t] = false; ++t;}
    }
    ans[1] = 1;
    int T = 0;
    while(cin >> N){
        if(T) cout << "\n";
        cout << "Case " << ++T << ":\n";
        solve(2);
    }
    return 0;
}